<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Attributes</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="language.basic.syntax.html" title="Chapter 3. Basic Syntax">
<link rel="prev" href="language.syntax.functions.html" title="Functions">
<link rel="next" href="language.syntax.quotes.html" title="Embedding Vars in Double Quotes">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Attributes</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="language.syntax.functions.html">Prev</a> </td>
<th width="60%" align="center">Chapter 3. Basic Syntax</th>
<td width="20%" align="right"> <a accesskey="n" href="language.syntax.quotes.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="Attributes">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="language.syntax.attributes"></a>Attributes</h2></div></div></div>
<p>
  Most of the <a class="link" href="language.syntax.functions.html" title="Functions">functions</a>
  take attributes that specify or modify
  their behavior. Attributes to Smarty functions are much like HTML
  attributes. Static values don't have to be enclosed in quotes, but it
  is required for literal strings. Variables with or without modifiers may also be used, and
  should not be in quotes. You can even use PHP function results, plugin results and complex expressions.
 </p>
<p>
  Some attributes require boolean values (<code class="constant">TRUE</code> or <code class="constant">FALSE</code>). These
  can be specified
  as <code class="literal">true</code> and <code class="literal">false</code>. If an attribute has no value assigned
  it gets the default boolean value of true.
 </p>
<div class="example">
<a name="id344316"></a><p class="title"><b>Example 3.4. function attribute syntax</b></p>
<div class="example-contents"><pre class="programlisting">

{include file="header.tpl"}

{include file="header.tpl" nocache}  // is equivalent to nocache=true

{include file="header.tpl" attrib_name="attrib value"}

{include file=$includeFile}

{include file=#includeFile# title="My Title"}

{assign var=foo value={counter}}  // plugin result

{assign var=foo value=substr($bar,2,5)}  // PHP function result

{assign var=foo value=$bar|strlen}  // using modifier

{assign var=foo value=$buh+$bar|strlen}  // more complex expression

{html_select_date display_days=true}

{mailto address="smarty@example.com"}

&lt;select name="company_id"&gt;
  {html_options options=$companies selected=$company_id}
&lt;/select&gt;

  </pre></div>
</div>
<br class="example-break"><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>
    Although Smarty can handle some very complex expressions and syntax, it is a good rule of
    thumb to keep the template syntax minimal and focused on presentation. If you find your
    template syntax getting too complex, it may be a good idea to move the bits that do not
    deal explicitly with presentation to PHP by way of plugins or modifiers.
 </p>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="language.syntax.functions.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="language.basic.syntax.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="language.syntax.quotes.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Functions </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> Embedding Vars in Double Quotes</td>
</tr>
</table>
</div>
</body>
</html>
